home *** CD-ROM | disk | FTP | other *** search
-
-
- ;---------------------------------------------------------------------------
- ; KB.ASM - Version 1.0
- ;
- ; This module implements some keyboard interrupt handlers
- ;
- ; from Persistence of Vision Raytracer
- ; Copyright 1994 Persistence of Vision Team
- ; Copyright 1994 Christopher J. Cason.
- ;---------------------------------------------------------------------------
- ; NOTICE: This source code file is provided so that users may experiment
- ; with enhancements to POV-Ray and to port the software to platforms other
- ; than those supported by the POV-Ray Team. There are strict rules under
- ; which you are permitted to use this file. The rules are in the file
- ; named POVLEGAL.DOC which should be distributed with this file. If
- ; POVLEGAL.DOC is not available or for more info please contact the POV-Ray
- ; Team Coordinator by leaving a message in CompuServe's Graphics Developer's
- ; Forum. The latest version of POV-Ray may be found there as well.
- ;
- ; POV-Ray files may also be obtained from ftp.uwa.edu.au in pub/povray.
- ;
- ; This program was written in its entirety by Christopher J. Cason.
- ; Its use is freely and permanently granted to the POV-Team and POV users
- ; under the conditions specified in POVLEGAL.DOC.
- ;
- ; Author : C. J. Cason (cjcason@yarrow.wt.uwa.edu.au, CIS 100032,1644)
- ;
- ;---------------------------------------------------------------------------
-
- KB_TEXT segment byte public 'CODE'
-
- DGROUP group _DATA, _BSS
-
- assume cs:KB_TEXT, ds:DGROUP
-
- KB_TEXT ends
-
- _DATA segment word public 'DATA'
-
- oldSS dw 0
- oldSP dw 0
- oldPSP dw 0
- oldDTA dd 0
- thestack db 128 dup ('STACK ')
- stacksize equ $ - thestack
-
- extrn _in_0x09:word
- extrn _in_0x15:word
- extrn _old0x15:dword
- extrn _in_0x16:word
- extrn _old0x16:dword
- extrn _running:word
- extrn _popped_up:word
- extrn _popdown:word
- extrn _paste:word
- extrn _home:word
- extrn _scancode:word
- extrn _scanflag:word
- extrn __psp:word
- extrn _ourDTA:word
-
- _DATA ends
-
- _BSS segment word public 'BSS'
- _BSS ends
-
- KB_TEXT segment byte public 'CODE'
-
- _CS_old0x16 dd 0
- in16 dw 0
- _CS_old0x15 dd 0
- in15 dw 0
-
- KB_TEXT ends
-
- KB_TEXT segment byte public 'CODE'
-
- _new0x16 proc far
-
- cmp cs:in16, 00h
- jnz notOK
-
- cmp ah, 00h ; get char
- jz ok
- cmp ah, 01h ; is char waiting ?
- jz ok
- cmp ah, 10h ; get char, extended
- jz ok
- cmp ah, 11h ; is char waiting ?, extended
- jz ok
-
- notOK:
- jmp dword ptr cs:_CS_old0x16 ; re-entry ocurred, bail out
-
- ok:
- inc cs:in16 ; so we don't re-enter
- push bx
- push cx
- push dx
- push es
- push ds
- push si
- push di
- push bp
- mov bp,DGROUP
- mov ds,bp
- push ax
-
- mov ax, word ptr DGROUP:_in_0x16
- inc word ptr DGROUP:_in_0x16
- or ax, ax
- jnz skip
- cmp word ptr DGROUP:_running,0
- jz skip
- cmp word ptr DGROUP:_popped_up,0
- jnz skip
- inc word ptr DGROUP:_popped_up
-
- mov ah, 62h ; get current PSP
- int 21h
- mov oldPSP, bx ; store it
- mov bx, __psp ; our PSP
- mov ah, 50h ; set PSP
- int 21h
-
- mov ah, 2fh ; get DTA
- int 21h
- mov word ptr oldDTA [0], bx
- mov word ptr oldDTA [2], es
-
- push ds
- mov ah, 1ah ; set DTA
- mov dx, 128
- mov ds, __psp
- int 21h
- pop ds
-
- mov oldSS,ss
- mov oldSP,sp
- mov ss,bp
- mov sp,offset DGROUP:thestack + stacksize
-
- sti
- call far ptr _popup
-
- mov ss,oldSS
- mov sp,oldSP
-
- push ds
- mov ah, 1ah ; set DTA
- lds dx, oldDTA
- int 21h
- pop ds
-
- mov bx, oldPSP ; old PSP
- mov ah, 50h ; set PSP
- int 21h
-
- mov word ptr DGROUP:_popped_up, 0
- mov word ptr DGROUP:_running, 0
- mov word ptr DGROUP:_popdown, 0
-
- skip:
- pop ax
- pushf
- call dword ptr DGROUP:_old0x16
- pushf
- dec word ptr DGROUP:_in_0x16
- popf
- pop bp
- pop di
- pop si
- pop ds
- pop es
- pop dx
- pop cx
- pop bx
- pushf
- dec cs:in16
- popf
- ret 2
-
- _new0x16 endp
-
- KB_TEXT ends
-
- public _new0x16
- public _CS_old0x16
- ; public _new0x15
- ; public _CS_old0x15
-
- extrn _popup:far
- end